<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="/pages/common/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String tempPath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ "/";
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
   
    <title>服务商平台</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
    <!-- 当前页面样式 -->
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
	<link href="<s:url value="/css/index.css"/>" type="text/css" rel="stylesheet"/>
	<script type="text/javascript" src="<s:url value="/js/jquery-1.9.1.js" />"></script>
	<script type="text/javascript" src="<s:url value="/js/jquery.slideunlock.js" />"></script> 
	<script type="text/javascript">
	var ischeck= false;
	var isSend = false;
	var isvalidate = false;
	$(document).ready(function() {
		var slider = new SliderUnlock("#slider",{
            successLabelTip : "验证成功"
        },function(){
        	ischeck= true;
        });
        slider.init();
		if($("#flag").val()==1){
			$("#forgetPwdDIV").show();
			$("#sendMsg").hide();
			$("#newPwd").hide();
			$("#success").hide();
			if($("#msg").val()!=""){
				alert($("#msg").val());
			}
		}else if($("#flag").val()==2){
			$("#forgetPwdDIV").hide();
			$("#sendMsg").show();
			$("#newPwd").hide();
			$("#success").hide();
			if($("#msg").val()!=""){
				alert($("#msg").val());
			}
		}else if($("#flag").val()==3){
			$("#forgetPwdDIV").hide();
			$("#sendMsg").hide();
			$("#newPwd").show();
			$("#success").hide();
			if($("#msg").val()!=""){
				alert($("#msg").val());
			} 
		}else if($("#flag").val()==4){
			$("#forgetPwdDIV").hide();
			$("#sendMsg").hide();
			$("#newPwd").hide();
			$("#success").show();
		}
		//异步校验登录名是否存在
        $("#accountNo").blur(function(){
        	if(this.value.length==0){
        		
        		var slider = new SliderUnlock("#slider",{
	  	            successLabelTip : "验证成功"
	  	        },function(){
	  	        	ischeck= true;
	  	        });
	  	        slider.init();
	  	        ischeck= false;
        		
        		alert("请输入登录名");
        		return;
        	}
        	var  name=this.value;
        	$.ajax({
        		url:"<%=basePath%>forget/getForgetPwdAccount.ct",
		  		data:{"accountNo":name},
		  		dataType:"json",
		  		type:"POST",
		  		async:false,
		  		success:function(result){
			  		 var codes=result.code;
			  		 if(codes=="0"){
			  			 
			  			var slider = new SliderUnlock("#slider",{
			  	            successLabelTip : "验证成功"
			  	        },function(){
			  	        	ischeck= true;
			  	        });
			  	        slider.init();
			  	        ischeck= false;
			  			 
			  			alert(result.codeDesc);
			  			$("#accountNo").val("");
			  		 }
		  		},error:function(rsg){
		  		}
        	});
        });
    	//提交到发短信页面
    	$("#forgetPwdID").click(
					function() {
					var accountNo=$("#accountNo").val();
					var flag=true;
						if(accountNo==null||accountNo==''){
							var slider = new SliderUnlock("#slider",{
				  	            successLabelTip : "验证成功"
				  	        },function(){
				  	        	ischeck= true;
				  	        });
				  	        slider.init();
				  	        ischeck= false;
							
							alert("账号不能为空");
							flag=false;
							return false;
						}
						if(!ischeck){
							alert("请拖动滑块验证");
							flag=false;
							return false;
						}
					if(flag==true){
						$("#loginForm").submit();
					}
		 });
       	//异步校验输入的短信验证码是否正确
        <%-- $("#verifyCode").blur(function(){
         	var verifyCode=$("#verifyCode").val();
        	if(isSend==false){
          		alert("请先获取验证码");
        		return;
        	}
          	if(verifyCode.length==0){
          		alert("请输入验证码");
        		return;
        	}
          	var  name=this.value;
          	$.ajax({
          		url:"<%=basePath%>forget/validateCode.ct",
  		  		data:{"verifyCode":verifyCode},
  		  		dataType:"json",
  		  		type:"POST",
  		  	    async:false,
  		  		success:function(result){
  		  			var re = result.parseJSON();
  		  			console.warn(re);
  			  		 var codes=result.code;
  			  		 if(codes=="0"){
  			  			alert("验证码错误");
  			  		 }else{
  			  			isvalidate = true;
  			  		 } 
  		  		},error:function(rsg){
  		  			  
  		  		}
          	});
        }); --%>
    	//设置密码页面
    $("#setPwdPageID").click(
				function() {
					var verifyCode=$("#verifyCode").val();
		        	if(isSend==false){
		          		alert("请先获取验证码");
		        		return;
		        	}
		          	if(verifyCode.length==0){
		          		alert("请输入验证码");
		        		return;
		        	}
		          	var  name=this.value;
		          	$.ajax({
		          		url:"<%=basePath%>forget/validateCode.ct",
		  		  		data:{"verifyCode":verifyCode},
		  		  		dataType:"json",
		  		  		type:"POST",
		  		  	    async:false,
		  		  		success:function(result){
		  			  		 var codes=result.code;
		  			  		 if(codes=="0"){
		  			  			alert("验证码错误");
		  			  		 }else{
		  			  			isvalidate = true;
		  			  			$("#loginFormSetPwdPage").submit();
		  			  		 } 
		  		  		},error:function(rsg){
		  		  			  
		  		  		}
		          	});
				if(flag==true){
					
				}
	});
    
    $("#newPwdSubmit").click(
				function() {
				var newPassWord=$("#newPassWord").val();
				var flag=true;
					if(newPassWord==null||newPassWord==''){
						alert("密码不能为空");
						flag=false;
						return false;
					}
					if(newPassWord.length < 8){
						alert("密码不能小于8位");
						flag=false;
						return false;
					}
				var rePassWord=$("#rePassWord").val();
				var flag=true;
					if(rePassWord==null||rePassWord==''){
						alert("密码不能为空");
						flag=false;
						return false;
					}
					if(newPassWord!=rePassWord){
						alert("两次输入密码不一致");
						flag=false;
						return false;
					}
					
				var flag=true;
				if(flag==true){
					$("#newPwdForm").submit();
				}
	 });
   //返回到登录页面
    $("#returnLogin").click(
		function() {
			$("#returnLoginForm").submit();
	 });
   
  //获取短信验证码
	var validCode=true;
	$("#reGet").click (function  () {
		var time=60;
		var code=$(this);
		if (validCode) {
			validCode=false;
		var t=setInterval(function  () {
			isSend=true;
			time--;
			$("#reGet").attr("disabled",true);
			$("#reGet").val(time+"秒");
			if (time==0) {
				clearInterval(t);
			$("#reGet").val("重新获取");
			isSend=false;
			isvalidate=false;
			$("#reGet").attr("disabled",false);
				validCode=true;
			}
		},1000)
		}

// 		var mobile = $("#mobile").val();
		$.ajax({
      		url:"<%=basePath%>forget/sendMsg.ct",
// 		  		data:{"mobile":mobile},
		  		dataType:"json",
		  		type:"POST",
		  		success:function(result){
		  			//alert(result.codeDesc);
			  		// $("#verifyCode").html(result.codeDesc);
  			  		 if(result=="0"){
  			  			alert("验证码发送失败！请联系客户人员！");
  			  		 }else{
  			  		 }
		  		},error:function(rsg){
		  			  
		  		}
      	});
	})
})
    
</script>
  </head>
  <body>
<s:hidden id="flag" name="flag" value="%{#request.flag}"/>
<s:hidden id="msg" name="msg" value="%{#request.msg}"/>
<%-- <s:hidden id="validateMsg" name="validateMsg" value="%{#request.validateMsg}"/> --%>
<div class="global-wrap">
    <div class="logo-title">
        <i class="icon icon-logo"></i>
        <h1>服务商平台</h1>
    </div>

    <div class="theme">
        <i class="icon icon-theme"></i>
    </div>
	<div class="retake" id="forgetPwdDIV">
        <h2 class="retake-title">找回密码</h2>
        	<s:form  id="loginForm" action="sentMsgPage.ct" method="post" theme="simple">
		        <div class="retake-cnt">
		            <div class="line">
		                <s:textfield  id="accountNo"  name="accountNo"  placeholder="请输入登录帐号" maxlength="15" onkeydown="if(event.keyCode==13)return false;" />
		                <i class="icon icon-1"></i>
		            </div>
		            <div class="line">
		                <div id="slider">
		                    <div id="slider_bg"></div>
		                    <span id="label">&gt;&gt;</span> <span id="labelTip">拖动滑块验证</span>
		                </div>
				    </div>
		        </div>
		        <div class="login-ft">
		            <input class="btn" id="forgetPwdID" type="button" value="下一步"/>
		        </div>
	        </s:form>
    </div>
    
    <div class="retake" id="sendMsg">
        <h2 class="retake-title">找回密码</h2>
        <s:form  id="loginFormSetPwdPage" action="setPwdPage.ct" method="post" theme="simple">
	        <div class="retake-cnt">
	            <p class="hint">通过手机<s:property value="#request.mobileDesc"/>获取验证码</p>
<%-- 	            <s:hidden id="mobile" name="mobile"/> --%>
	            <div class="line" style="width: 230px;">
	                <i class="icon icon-6"></i>
	                <s:textfield id="verifyCode" name="verifyCode" maxlength="6" placeholder="请输入手机收到的验证码" style="width: 135px;float: left;" onkeydown="if(event.keyCode==13)return false;"></s:textfield>
	                <input type="button" id="reGet" value="获取短信验证码" style="width: 90px;padding: 0;text-align: center;float: left;margin-left: 5px;"/>
	            </div>
	        </div>
	        <div class="login-ft">
	            <input class="btn" type="button" id="setPwdPageID" value="下一步"/>
	        </div>
        </s:form>
    </div>

    <div class="retake" id="newPwd">
        <h2 class="retake-title">设置新密码</h2>
        <s:form  id="newPwdForm" action="setPwdSubmit.ct" method="post" theme="simple">
	        <div class="retake-cnt">
	            <p class="hint">密码长度8-12位，必须是字母与数字组合</p>
	            <div class="line">
	                <i class="icon icon-2"></i>
	                <s:password id="newPassWord" type="passwd" name="newPassWord" placeholder="请输入密码" maxlength="15" />
	             </div>
	            <div class="line">
	                <i class="icon icon-2"></i>
	                <s:password id="rePassWord" name="rePassWord" placeholder="请再次确认密码" maxlength="15" />
	            </div>
	        </div>
	        <div class="login-ft">
	            <input class="btn" id="newPwdSubmit" type="button" value="提交"/>
	        </div>
        </s:form>
    </div>
    <div class="retake" id="success">
    	<s:form  id="returnLoginForm" action="returnLoginPage.ct" method="post" theme="simple">
	        <h2 class="retake-title">修改密码成功</h2>
	        <div class="retake-cnt">
	            <i class="icon icon-7"></i>
	            <p class="hint">恭喜！您已成功修改了帐号的登陆密码</p>
	        </div>
	        <div class="login-ft">
	            <input class="btn" id="returnLogin" type="button" value="返回登陆"/>
	        </div>
        </s:form>
    </div>

</div>
</body>
</html>
